<template>
  <div class="inventory-check">
    <el-form :model="formData" ref="form" :rules="rules" label-width="120px">
      <div class="form-section">
        <h3>盘点核对</h3>
        
        <el-table
          :data="formData.items"
          border
          style="width: 100%">
          <el-table-column prop="assetNo" label="资产编号" width="150"></el-table-column>
          <el-table-column prop="assetName" label="资产名称" width="180"></el-table-column>
          <el-table-column prop="bookValue" label="账面数量"></el-table-column>
          <el-table-column prop="actualValue" label="实盘数量">
            <template slot-scope="scope">
              <el-input-number v-model="scope.row.actualValue" :min="0"></el-input-number>
            </template>
          </el-table-column>
          <el-table-column prop="difference" label="差异">
            <template slot-scope="scope">
              {{ scope.row.actualValue - scope.row.bookValue }}
            </template>
          </el-table-column>
          <el-table-column prop="reason" label="差异原因">
            <template slot-scope="scope">
              <el-input v-model="scope.row.reason"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </div>

      <div class="form-actions">
        <el-button @click="prevStep">上一步</el-button>
        <el-button type="primary" @click="submitForm">下一步</el-button>
      </div>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'InventoryCheck',
  data() {
    return {
      formData: {
        items: [
          { assetNo: 'ZC001', assetName: '台式电脑', bookValue: 10, actualValue: 9, reason: '' },
          { assetNo: 'ZC002', assetName: '打印机', bookValue: 5, actualValue: 5, reason: '' }
        ]
      },
      rules: {}
    }
  },
  methods: {
    prevStep() {
      this.$emit('prev-step')
    },
    submitForm() {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.$emit('next-step', this.formData)
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.inventory-check {
  .form-section {
    margin-bottom: 30px;
    
    h3 {
      margin: 0 0 20px;
      padding-left: 10px;
      border-left: 4px solid #409EFF;
      font-size: 18px;
      font-weight: 500;
      color: #303133;
    }
  }

  .form-actions {
    text-align: center;
    margin-top: 40px;
  }
}
</style> 